<?php
/**
 * @authors alex (20779512@qq.com)
 * @date    2014-03-24 16:49:33
 * @version 1.0
 */

class TejiaAction extends HomeAction {

    //商品分类列表
    public function cate(){
        $list = M('ShopCate')->select();
        $this->assign('list',$list);
        $this->display();
    }

    //商品列表
    public function index(){        
        $cid=I("cid",0);
        $order=I("order","id")=="time"?"id":I("order","id");
        $method=I("method","desc");
        //当前分类
        if($cid>0){
            $cate=M("ShopCate")->where("id=".$cid."")->find();
            $map['cid']=$cid;
        }else{
            $cate=array("name"=>"全部商品","id"=>0);
        }
        $this->assign("cate",$cate);
        //产品列表
        $map['show']=1;
        //$map['tejia']=1;
        $list = M('Goods')->where($map)->order($order." ".$method)->field('id,name,picname,baoxian,price,shichang,sellNumber')->limit(8)->select();
        $this->assign('list',$list);
        $this->assign('order',$order=="id"?"time":$order);
        $this->assign('method',$method);
        $this->assign('total',M('Goods')->where($map)->count());
        $this->assign('action','index');
        $this->assign('catefocus',"am-icon-focus");
        $this->display();
    }       
}